home *** CD-ROM | disk | FTP | other *** search
/ APDL Eductation Resources / APDL Eductation Resources.iso / programs / misc / gravity / !Gravity / !Help next >
Encoding:
Text File  |  1994-07-01  |  2.6 KB  |  56 lines

  1. Gravity Simulator
  2. =================
  3.  
  4. by JJF
  5.  
  6.  
  7. This program seemed like a nice idea in the beginning. Write an ARM code
  8. gravity simulator and sell it to Acorn User for a vast sum of cash. However,
  9. the program didn't work quite as I'd anticipated, and I ended up with
  10. something I am nervous about even sending to a PD library, let alone a
  11. magazine.
  12.  
  13. The program uses Newton's Law of Gravitation to discover the force which is
  14. exerted on each object. Basically, for those unfamiliar with this, the law
  15. states that :
  16.  
  17.   F = G M m / (r^2)
  18.  
  19. Where F is the force between two objects, M and m are their masses, and r is
  20. the distance between them, whilst G is some constant. Then, Newton's Second
  21. Law (F=ma) is applied to this equation, leaving us with :
  22.  
  23.   a = G M / (r^2)
  24.  
  25. Where a is the acceleration that is caused on an object by a second object
  26. of mass M. This acceleration is resolved in horizontal and vertical
  27. directions, and, after all the forces exerted on the object are considered,
  28. the components of the accalerations are added up and added onto the velocity
  29. of the object. Then the next object is considered in the same manner.
  30.  
  31. The first problem is that the force between two objects on different sides
  32. of the screen is miniscule; in fact, since it is held 'scaled up' by a
  33. massive factor (since the ARM chip cannot handle fractions), it is far too
  34. small to register unless G is very large. However, when G is very large,
  35. the forces experienced when two objects are close are phenomenal - far too
  36. large, in fact, and the objects suddenly go streaking off into the sunset.
  37.  
  38. The second problem is that the gravity simulation is 
  39. The other problem I encountered was that the animation is mysteriously 
  40. very jerky. I have since succeeded in fixing this, however...
  41.  
  42. There are three variables defined early in the !RunImage file that you might
  43. like to alter. The first, bouncedamp, is a number by which the velocity of
  44. an object colliding with the side of the screen is 'damped' - it is mainly
  45. just to prevent velocities from becoming too high. The second, sqrdamp, is
  46. provided to 'damp' the gravitational force between objects that are close
  47. together. Basically, an object has a uniform gravitational field up to a
  48. distance of sqrdamp from it, with Newton's Law of Gravitation applying at
  49. distances above this. The final variable, G, controls the strength of the
  50. gravitational forces. The higher the value of G, the more particles attract.
  51.  
  52. Feel free to muck about with the program to your heart's content. It is
  53. entirely PD, so, if you think that you can improve it, then feel free. I
  54. might feel a bit hurt if you try to pass it off as all your own work,
  55. though...
  56.